package edu.chalmers.AV_2DPlatformerFramework.Model;

import edu.chalmers.AV_2DPlatformerFramework.Utility.Utility;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;

/**
 * TextureTiles, unlike regular Textures, do not change based on their anchor.
 * @version 1.0
 * @author Richard
*/
public class TileTexture extends Texture {

    public TileTexture(String imageURL, Shape anchor) {
        super(imageURL, getResizedAnchor(Utility.generateBufferedImage(imageURL)));
    }
    
    public TileTexture(BufferedImage bImg, Shape anchor) {
        super(bImg, getResizedAnchor(bImg));
    }
    
        /**
     * Returns the tile as-is. New anchor isn't used, and is only included to ensure matching method signature.
     * @param newAnchor Not used, can be null.
     * @return this, as is.
     */
    @Override
    public Texture getUpdatedTexture(Rectangle2D newAnchor){
          return this;
    }
    
    private static Rectangle2D getResizedAnchor(BufferedImage t){
        return new Rectangle2D.Double(0,0,t.getWidth(),t.getHeight());
    }
    
    @Override
    public TileTexture copy(){
        return new TileTexture(this.getImage(), this.getAnchorRect());
    }
}
